package com.example.demo.reflect.proxy;

import com.example.demo.reflect.proxy.impl.PersonServiceImpl;
import java.lang.reflect.Proxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author xkx
 * @description
 * @since 2019/3/22 18:22
 */
public class ProxyTest {
  public static final Logger logger = LoggerFactory.getLogger(ProxyTest.class);

  public static void main(String[] args) {
    PersonServiceImpl personService = new PersonServiceImpl();

    PersonService newProxyInstance = (PersonService)Proxy.newProxyInstance(personService.getClass().getClassLoader(),
        personService.getClass().getInterfaces(), new PersonServiceProxy(personService));
    newProxyInstance.doSomething();
    newProxyInstance.saySomething();
    logger.info(newProxyInstance.getClass().getName());
  }
}
